local shixue = fk.CreateSkill{
    name = "st__shixue",
    tags = { Skill.Compulsory },
}
shixue:addEffect(fk.Damage,{
    can_trigger = function (self, event,target,player,data)
        return target == player and target:hasSkill(self.name)
    end,
    trigger_times = function(self, event, target, player, data)
        return data.damage
    end,
    on_use = function(self, event, target, player, data)
        player.room:addPlayerMark(player, "@shixue_xue")
    end,
})
shixue:addEffect("active", {
  anim_type = "support",
  prompt = "#shixue",
  card_num = 0,
  min_target_num = 1,
  max_target_num = 1,
  interaction = function(self, player)
    local choiceList = {
      "shixue_draw",
      "shixue_recover",
      "shixue_paoxiao",
      "shixue_kuanggu",
      "shixue_hpmax"
    }
    local choices = {}
    local markValue = player:getMark("@shixue_xue")
    if markValue >= 1 then
      table.insert(choices, choiceList[1])
      table.insert(choices, choiceList[2])
    end
    if markValue >= 2 then
      table.insert(choices, choiceList[3])
      table.insert(choices, choiceList[4])
    end
    if markValue >= 3 then
        table.insert(choices, choiceList[5])
    end
    return UI.ComboBox { choices = choices, all_choices = choiceList }
  end,
  times = function(self, player)
    return player.phase == Player.Play and 2 - player:usedEffectTimes(self.name, Player.HistoryPhase) or -1
  end,
  can_use = function(self, player)
    return player:usedEffectTimes(self.name, Player.HistoryPhase) < 2 and player:getMark("@shixue_xue") > 0
  end,
  target_filter = function(self, player, to_select, selected, selected_cards)
        if #selected > 0 then
            return false
        end
        return true
    end,
  feasible = function (self, player, selected, selected_cards, card)
        local choice = self.interaction.data
        local markValue = player:getMark("@shixue_xue")
        if choice == "shixue_draw" or choice == "shixue_recover" then
            return markValue >= 1
        elseif choice == "shixue_paoxiao" or choice == "shixue_kuanggu" then
            return markValue >= 2
        elseif choice == "shixue_hpmax" then
            return markValue >= 3
        end
        return false
    end,
  on_use = function(self, room, effect)
    ---@type string
    local skillName = shixue.name
    local player = effect.from
    local target = effect.tos[1]

    local choice = self.interaction.data
    if choice == "shixue_draw" then
      room:removePlayerMark(player, "@shixue_xue", 1)
      target:drawCards(2, skillName)
    elseif choice == "shixue_recover" then
      room:removePlayerMark(player, "@shixue_xue", 1)
      room:recover({
        who = target,
        num = 1,
        recoverBy = player,
        skillName = skillName,
      })
    elseif choice == "shixue_paoxiao" then
      room:removePlayerMark(player, "@shixue_xue", 2)
      player.room:addPlayerMark(player, "paoxiao")
    elseif choice == "shixue_kuanggu" then
      room:removePlayerMark(player, "@shixue_xue", 2)
      player.room:addPlayerMark(player, "kuanggu")
    elseif choice == "shixue_hpmax" then
      room:removePlayerMark(player, "@shixue_xue", 3)
      room:changeMaxHp(target, 1)
      room:recover({
        who = target,
        num = 1,
        recoverBy = player,
        skillName = skillName,
      })
    end
end,
})
shixue:addEffect("targetmod", {
  bypass_times = function(self, player, skill, scope, card)
    if player:hasSkill(self.name) and card and skill.trueName == "slash_skill" and scope == Player.HistoryPhase
    and player:getMark("paoxiao") == 1  then
      return true
    end
  end,
})
shixue:addEffect(fk.Damage,{
    can_trigger = function (self, event,target,player,data)
        return target == player and target:hasSkill(self.name)
        and player:getMark("kuanggu") == 1 -- 修正拼写错误 "kuanfgu" 为 "kuanggu"
    end,
    trigger_times = function(self, event, target, player, data)
        return data.damage
    end,
    on_use = function(self, event, target, player, data)
        player:drawCards(1, self.name)
    end,
})
shixue:addEffect(fk.TurnEnd,{
    can_trigger = function (self, event,target,player,data)
    return target == player and target:hasSkill(self.name)
    end,
    on_use = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(player,"paoxiao",0)
    room:setPlayerMark(player,"kuanggu",0)
    end,
})
Fk:loadTranslationTable{
    ["st__shixue"]="嗜血",
    [":st__shixue"]="锁定技，每当你造成一点伤害后，获得一枚小面包标记，出牌阶段限两次，你可以移去至少1枚小面包，然后执行对应项：1枚，回复一点体力或摸两张牌；2枚，本回合使用杀无次数限制或本回合每造成一点伤害可以摸一张牌；3枚，加一点体力上限并回复一点体力",
    ["@shixue_xue"]="小面包",
    ["#shixue"] = "嗜血：你可以移去一定数量的小面包对自己进行增益",
    ["shixue_draw"]="摸两张牌",
    ["shixue_recover"]="回复一点体力",
    ["shixue_paoxiao"]="本回合使用杀无次数限制",
    ["shixue_kuanggu"]="本回合每造成一点伤害可以摸一张牌",
    ["shixue_hpmax"]="加一点体力上限并回复一点体力",
}
return shixue
